package com.member.shop.domain;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.member.common.annotation.Excel;
import com.member.common.config.RmConfig;
import com.member.common.constant.SystemConst;
import com.member.common.core.domain.BaseEntity;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import org.apache.commons.lang3.StringUtils;

import java.util.Date;
import java.util.List;

/**
 * 抽奖活动对象 sys_biz_raffle_activity
 *
 * @author lxc
 * @date 2024-03-14
 */
@Data
@SuperBuilder
@AllArgsConstructor
@NoArgsConstructor
@TableName("sys_biz_raffle_activity")
public class SysBizRaffleActivity extends BaseEntity {

    private static final long serialVersionUID = 1L;

    /**
     * 活动主键id
     */
    @TableId(type = IdType.AUTO)
    private Long id;

    /**
     * 活动标题
     */
    @Excel(name = "活动标题")
    private String title;

    /**
     * 活动状态(0:待开始，1.进行中，2:已结束)
     */
    @Excel(name = "活动状态(0:待开始，1.进行中，2:已结束)")
    private Long status;

    /**
     * 活动附标题
     */
    @Excel(name = "活动附标题")
    private String subtitle;

    /**
     * 活动开始时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd")
    @Excel(name = "活动开始时间", width = 30, dateFormat = "yyyy-MM-dd")
    private Date activityStartTime;

    /**
     * 活动截止时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd")
    @Excel(name = "活动截止时间", width = 30, dateFormat = "yyyy-MM-dd")
    private Date activityEndTime;

    /**
     * 活动封面
     */
    @Excel(name = "活动封面")
    private String cover;
    @TableField(exist = false)
    private String coverAbsolute;

    public String getCover() {
        return cover;
    }

    public void setCover(String cover) {
        this.cover = cover;
        coverAbsolute = cover;
        String domain = RmConfig.getDomain();
        if (StringUtils.isNotEmpty(cover) && !cover.startsWith(SystemConst.HTTP)) {
            coverAbsolute = domain + cover;
        }
    }

    public String getCoverAbsolute() {
        return coverAbsolute;
    }

    public void setCoverAbsolute(String coverAbsolute) {
        this.coverAbsolute = coverAbsolute;
    }

    /**
     * 活动背景图片
     */
    @Excel(name = "活动背景图片")
    private String backgroundImageUrl;
    @TableField(exist = false)
    private String backgroundImageUrlAbsolute;

    public String getBackgroundImageUrl() {
        return backgroundImageUrl;
    }

    public void setBackgroundImageUrl(String backgroundImageUrl) {
        this.backgroundImageUrl = backgroundImageUrl;

        backgroundImageUrlAbsolute = backgroundImageUrl;
        String domain = RmConfig.getDomain();
        if (StringUtils.isNotEmpty(backgroundImageUrl) && !backgroundImageUrl.startsWith(SystemConst.HTTP)) {
            backgroundImageUrlAbsolute = domain + backgroundImageUrl;
        }
    }

    public String getBackgroundImageUrlAbsolute() {
        return backgroundImageUrlAbsolute;
    }

    public void setBackgroundImageUrlAbsolute(String backgroundImageUrlAbsolute) {
        this.backgroundImageUrlAbsolute = backgroundImageUrlAbsolute;
    }

    /**
     * 排序
     */
    @Excel(name = "排序")
    private Long sort;

    /**
     * 是否发布(0:已发布，1:未发布)
     */
    @Excel(name = "是否发布(0:已发布，1:未发布)")
    private Long displayed;

    /**
     * 最多参与次数
     */
    @Excel(name = "最多参与次数")
    private Long maxParticipationCount;

    /**
     * 规则类型(1:概率模式，2.趋于用户，3:管控模式)
     */
    @Excel(name = "规则类型(1:概率模式，2.趋于用户，3:管控模式)")
    private Long raffleType;

    /**
     * 每天参与次数
     */
    @Excel(name = "每天参与次数")
    private Long dailyParticipationCount;

    /**
     * 最多中奖次数
     */
    @Excel(name = "最多中奖次数")
    private Long maxWinningCount;

    /**
     * 趋于用户(抽奖用户总数量)
     */
    @Excel(name = "趋于用户(抽奖用户总数量)")
    private Long tendUserCount;

    /**
     * 活动详情
     */
    @Excel(name = "活动详情")
    private String details;

    /**
     * 趋于用户(累加:第几次)
     */
    @Excel(name = "趋于用户(累加:第几次)")
    private Long tendUserSum;

    /**
     * 是否删除(0：未删除，1：删除)
     */
    private Long deleted;

    /**
     * 抽奖活动奖品对应关系
     */
    @Excel(name = "抽奖活动奖品对应关系")
    @TableField(exist = false)
    private List<SysBizRaffleActivityPrize> sysBizRaffleActivityPrize;

    /**
     * 奖品表
     */
    @Excel(name = "奖品表")
    @TableField(exist = false)
    private List<SysBizRafflePrize> sysBizRafflePrize;

}
